package P061_VariableLengthArray;

import org.junit.Test;

import java.util.Arrays;

/**
 *变长数组
 */
public class VariableLengthArray {

    public static <T> T[] expandCapacity(T[] datas, int length) {
        length = length < 0 ? 0 : length;
        return Arrays.copyOf(datas, length);
    }

    @Test
    public void Test() {
        String[] strings = new String[10];
        System.out.println(strings.length);
        strings = expandCapacity(strings, 15);
        System.out.println(strings.length);
    }
}
